package com.Txunda.fxw.ui.base;

import android.content.Context;
import android.os.Bundle;

import com.Txunda.fxw.base.BaseFragment;

/**
 * @author Txunda_Hzj
 * <p>
 * 2016
 */
public abstract class BaseFgt extends BaseFragment {

    protected boolean isVisible;
    protected Context mContext;

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

        if (getUserVisibleHint()) {
            isVisible = true;
            onVisible();
        } else {
            isVisible = false;
            onInvisible();
        }
    }

    /**
     * 閸欘垵顫�?
     */
    protected void onVisible() {

    }

    /**
     * 娑撳秴褰茬憴锟�
     */
    protected void onInvisible() {

    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
    }

//	@SuppressLint("InlinedApi")
//	protected void setImmerseLayout(View view) {
//		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//			Window window = getActivity().getWindow();
//			/*
//			 * window.setFlags(WindowManager.LayoutParams.
//			 * FLAG_TRANSLUCENT_STATUS,
//			 * WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//			 */
//			window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//
//			int statusBarHeight = getStatusBarHeight(getActivity().getBaseContext());
//			view.setPadding(0, statusBarHeight, 0, 0);
//		}
//	}


    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }

}
